package com.way.Java多线程编程核心技术v2.chapter02_对象及变量的并发访问._2_2_synchronized同步语句块.内置类与同步;

/**
 * @author 魏彪
 */
public class Test02 {

    public static void main(String[] args) {
        final OutClass01.InnerClass1 in1 = new OutClass01.InnerClass1();
        final OutClass01.InnerClass2 in2 = new OutClass01.InnerClass2();

        Thread t1 = new Thread(new Runnable() {
            public void run() {
                // 类锁
                in1.method1(in2);
            }
        }, "T1");

        Thread t2 = new Thread(new Runnable() {
            public void run() {
                // 对象锁
                in1.method2();
            }
        }, "T2");

        Thread t3 = new Thread(new Runnable() {
            public void run() {
                in2.method1();
            }
        }, "T3");

        t1.start();
        t2.start();
        t3.start();
    }
}
